import { Injectable } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import { Repository } from 'typeorm';
import { ResourceModel } from './resource.model';

@Injectable()
export class ResourceService {
  constructor(
    @InjectRepository(ResourceModel)
    private readonly resourceModelRepository: Repository<ResourceModel>,
  ) {}

  async adminAll() {
    const res = await this.resourceModelRepository.find({
      select: [
        'uuid',
        'name',
        'sort',
        'parentUuid',
        'createTime',
        'updateTime',
      ],
      order: {
        parentUuid: 'ASC',
        sort: 'ASC',
        id: 'DESC',
      },
    });
    return res;
  }

}
